doing the basics:
Basically use gdt_SetBasicData() and gdt_SetBasicCode to create a template code and data segment and use everything else as required...

NOTE: GdtPtr should be set as a flat address space pointer!
NOTE: your if you use another gdt pointer variable it should be VOLATILE!


Function List:
note that gdt_index is what you would load divided by 8
for instance if your data segment is at 0x10 for segments then just do 0x10/8 which is 2
--(void *)pointer=gdt_Get_GdtPtr(void)--
this just gets the pointer stored in GdtPtr

--gdt_Set_GdtPtr(void *pointer)--
this just sets the GdtPtr to pointer

--(unsigned int)num_of_bytes=gdt_GetLimit(unsigned short gdt_index)--
This will get the number of bytes you have for a limit, note this is in BYTES NOT PAGES(it automatically adds it up for ya)

--(unsigned char)code=gdt_IsCode(unsigned short gdt_index)--
this returns 1 if the segment is code or 0 if it's data

--priveldge_level=gdt_GetDPL(unsigned short gdt_index)--
this returns what ring the segment is

--is_or_not=gdt_IsAccessed(unsigned short gdt_index)--
this returns 1 if the segment has been accessed or 0 if not

--is_or_not=gdt_IsConforming(unsigned short gdt_index)--
this returns 1 if the segment is a code segment is conforming
if the segment is a data segment then it returns 0

--is_or_not=gdt_IsExpandDown(unsigned short gdt_index)--
this returns 1 if the segment is a data segment and is set for expand-down

--base_in_bytes=gdt_GetBase(unsigned short gdt_index)--
This returns what the base is in bytes

--is_or_not=gdt_IsReadable(unsigned short gdt_index)--
This returns 1 if the segment is a code segment and the readable bit is set to 1
for data segments it is always 1

--is_or_not=gdt_IsWriteable(unsigned short gdt_index)--
This returns 1 if the segment is a data segment and the writable bit is 1
for a code segment it always returns 0

--is_or_not=gdt_IsPresent(unsigned short gdt_index)--
this should return 1 if the present bit is 1

--is_or_not=gdt_Is32Bit(unsigned short gdt_index)--
This returns 1 if the segment uses 32bit opcodes/stack or 0 if it is 16bit

--uses_or_not=gdt_Uses4kPaging(unsigned short gdt_index)--
This returns 1 if the segment uses 4k paging(the granularity bit is set) or 0 if it uses byte addressing

--can_or_not=gdt_CanAccessThis(unsigned short gdt_index,void *what)--
This returns 1 if the current segment can access the memory location(what) in the segment(gdt_index)

--can_or_not=gdt_CanReadThis(unsigned short gdt_index,void *what)--
This returns 1 if the current segment can read the memory location(what) in the segment(gdt_index)

--can_or_not=gdt_CanWriteThis(unsigned short gdt_index,void *what)--
This returns 1 if the current segment can write to the memory location(what) in the segment(gdt_index)

--can_or_not=gdt_CanExecuteThis(unsigned short gdt_index,void *what)--
This returns 1 if the current segment can execute the memory location(what) in the segment(gdt_index)

--can_or_not=gdt_CanAccess(unsigned short gdt_index)--
This returns 1 if the current segment can access memory in the other segment(gdt_index)

--can_or_not=gdt_CanRead(unsigned short gdt_index)--
This returns 1 if the current segment can read memory in the other segment(gdt_index)

--can_or_not=gdt_CanWrite(unsigned short gdt_index)--
This returns 1 if the current segment can write memory in the other segment(gdt_index)

--can_or_not=gdt_CanExecute(unsigned short gdt_index)--
This returns 1 if the current segment can execute memory in the other segment(gdt_index)

--(void *)ptr_to_use=gdt_SegmentToFlat(unsigned short gdt_index,void *segmented)--
This will translate the segmented address(segmented) in the segment(gdt_index) to a flat address space address
warning: this doesn't check for overflow or anything like that

--(void *)ptr_to_use=gdt_FlatToSegment(unsigned short gdt_index,void *flat)--
This will translate the flat address(flat) to a segmented address suitable for the segment in gdt_index
warning: you should always use CanAccessThis(gdt_index,ptr_to_use) to make sure no overflow or anything happened

--theres another function but not sure if I'll include it..--

--is_or_not=gdt_IsData(unsigned short gdt_index)--
This returns 1 if the segment is a data segment or 0 if it's a code segment

--actual_limit=gdt_SetLimit(unsigned short gdt_index,unsigned int limit_in_bytes)--
This sets the segment(gdt_index) to have the limit limit_in_bytes with proper calculations for paging
this will set the gran bit if limit is over 0xFFFFF and converts the limit to use paging(with rounding)
it will return what the actual limit is loaded into gdt_index

--gdt_SetLimit_NoGran(unsigned short gdt_index,unsigned int limit)--
This will set the limit of the gdt to [limit] but will not do any thing to convert it to paging nor modify the gran bit

--gdt_SetBase(unsigned short gdt_index,unsigned int base)--
this sets the segment base of gdt_index to [base]

--gdt_SetAccess(unsigned short gdt_index,unsigned char accessed)--
This sets the accessed bit of gdt_index to [accessed]

--gdt_SetPresent(unsigned short gdt_index,unsigned char present)--
this sets the present bit of gdt_index to [present]

--gdt_SetReadable(unsigned short gdt_index,unsigned char readable)--
This sets the gdt_index to readable(if readable is 1) if it's a code segment, otherwise nothing happens

--gdt_SetWriteable(unsigned short gdt_index,unsigned char writeable)--
this sets the gdt_index to writeable(if writeable is 1) if it's a data segment, otherwise nothing happens

--gdt_SetConforming(unsigned short gdt_index,conforming)--
This sets gdt_index to conforming(if conforming is 1) if it's a code segment, otherwise nothing happens

--gdt_SetExpandDown(unsigned short gdt_index,expand_down)--
This sets gdt_index to expand_down(if expand_down is 1) if it's a data segment, otherwise nothing happens

--gdt_SetCode(unsigned short gdt_index,code)--
This sets gdt_index to be a code segment if code=1 if code=0 then gdt_index is set to be a data segment

--gdt_SetToCode(unsigned short gdt_index)--
This makes gdt_index a code segment

--gdt_SetToData(unsigned short gdt_index)--
This makes gdt_index a data segment

--gdt_SetDPL(unsigned short gdt_index,unsigned char ring)--
This will set the priveledge level of gdt_index to ring

--gdt_SetGran(unsigned short gdt_index, unsigned char granularity)--
This will make gdt_index use 4k paging if granularity is 1 or byte addressing if granularity is 0

--gdt_Set32bit(unsigned short gdt_index,unsigned char bits32)--
This will make gdt_index a 32bit segment if bits32 is 1 or make it 16bit if bits32 is 0

--gdt_SetTo32Bit(unsigned short gdt_index)--
This will set gdt_index to be a 32bit segment

--gdt_SetTo16bit(unsigned short gdt_index)--
This will set gdt_index to be a 16bit segment

--gdt_SetForGdt(unsigned short gdt_index)--
This will initialize gdt_index for use as a gdt segment(data or code)
this should ALWAYS be called

--gdt_SetBasicData(unsigned short gdt_index)--
This will make gdt_index a basic, flat, writable, ring0, data segment

--gdt_SetBasicCode(unsigned short gdt_index)--
This will make gdt_index a basic, flat, readable, ring0, code segment




